// 数据源
import Vue from 'vue'
import Vuex from 'vuex'
import friend from "../api/friend.js"

Vue.use(Vuex);//vue的插件机制

//Vuex.Store 构造器选项
const store = new Vuex.Store({
    state:{//存放状态
		"sumUnReadNum": 0, // 未读消息总条数
		"message_location": -1, // 当前聊天窗口位置 -1表示不在聊天窗口
    },
	mutations: {
		// 设置当前所在位置
		setMessageLocation(state,location){
			state.message_location = location
		},
		// 设置当前所在位置
		setUnReadNum(state,number){
			state.sumUnReadNum += number
		},
		reduceUnReadNum(state,number){
			state.sumUnReadNum -= number
			if(state.sumUnReadNum < 0){
				state.sumUnReadNum = 0
			}
		},
	}
})
export default store